package com.atguigu.ssm.controller;

import com.atguigu.ssm.bean.TUser;
import com.atguigu.ssm.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DongZH
 * @content
 * @since 2024/4/1 - 23:31
 **/
@RestController
public class UserController {

    @Resource
    UserMapper userMapper;

    /**
     * 返回User的json数据
     * @param id
     * @return
     */
    @GetMapping("/user/{id}")
    public TUser getUser(@PathVariable("id") Long id) {
        System.out.println("进来了");
        TUser userById = userMapper.getUserById(id);
        System.out.println(userById);
        return userById;
    }
}
